<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>



<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="tutorial.css">
<TITLE>
Exercises
</TITLE>
</HEAD>
<BODY >
<A HREF="tutorial021.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="tutorial012.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<HR>

<H2 CLASS="section"><A NAME="htoc50">3.10</A>&nbsp;&nbsp;Exercises</H2>
<OL CLASS="enumerate" type=1><LI CLASS="li-enumerate"><BR>
<BR>
Consider again the &#8220;family tree&#8221; example (see Section&nbsp;<A HREF="tutorial016.html#syntax">3.4.2</A>).
As well as the <TT>parent/2</TT> predicate, suppose we have a
<TT>male/1</TT> predicate as follows:<BR>
<BR>

	<TABLE CELLPADDING=10>
<TR><TD BGCOLOR="#CCCCFF">
	<BLOCKQUOTE CLASS="quote"><PRE>
male(abe).
male(homer).
male(herbert).
male(bart).
</PRE></BLOCKQUOTE></TD>
</TR></TABLE><BR>
Define a <TT>brother/2</TT> predicate, expressed just in terms of
<TT>parent/2</TT> and <TT>male/1</TT>. Make sure Homer is not considered
his own brother.<BR>
<BR>
<LI CLASS="li-enumerate"><BR>
<BR>
Consider the following alternative definition of <TT>ancestor/2</TT>:<BR>
<BR>

	<TABLE CELLPADDING=10>
<TR><TD BGCOLOR="#CCCCFF">
	<BLOCKQUOTE CLASS="quote"><PRE>
ancestor(X, Y) :- parent(X, Y).
ancestor(X, Y) :- ancestor(X, Z), parent(Z, Y).
</PRE></BLOCKQUOTE></TD>
</TR></TABLE><BR>
What is wrong with this code? What happens if you use it to find out
who Bart is an ancestor of?</OL>
<HR>
<A HREF="tutorial021.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="tutorial012.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
</BODY>
</HTML>
